# modules/squid/manifests/init.pp - manage squid stuff
# Copyright (C) 2007 admin@immerda.ch
#

# modules_dir { "squid": }

class squid { 
  case $operatingsystem {
    gentoo: { include squid::gentoo }
    centos: { include squid::centos }
    default: { include squid::base }
  }
  
  if $use_munin {
    include squid::munin
  }
}


class squid::base {
  package { 'squid':
    ensure => present,
  }
  
  service{'squid':
    enable => true,
    ensure => running,
    hasstatus => true,
    require => Package[squid],
  }

  # call this with appropriate parameters to define squid.conf
  define squid_conf( $visible_hostname = $fqdn,
  $cache_size = "256", $squiddir = $squiddir) {
    file { "/etc/squid/squid.conf":
      path => "/etc/squid/squid.conf",      
      ensure => file,
      owner => root,
      group => root,
      mode => 644,
      content => template("squid/squid.conf/MASTER.erb"),
      require => Package["squid"],
      notify => Service[squid],      
    }
  }
  
}

class squid::gentoo inherits squid::base {
  Package[squid]{
    category => 'net-proxy',
  }
}

class squid::centos inherits squid::base {
  file{'/etc/sysconfig/squid':
    source => [ "puppet:///squid/sysconfig/squid"],
    require => Package['squid'],
    notify => Service['squid'],
    owner => root, group => 0, mode => '0644';
  }
}
